﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package com.facebook.utils {
    import flash.net.*;
    import com.facebook.data.*;
    import com.facebook.data.photos.*;

    public class FacebookXMLParserUtils {

        public static function createAlbumCollection(_arg1:XML, _arg2:Namespace):AlbumCollection{
            var _local4:*;
            var _local5:AlbumData;
            var _local3:AlbumCollection = new AlbumCollection();
            for each (_local4 in _arg1.._arg2::album) {
                _local5 = new AlbumData();
                _local5.aid = FacebookXMLParserUtils.toStringValue(_local4._arg2::aid[0]);
                _local5.cover_pid = FacebookXMLParserUtils.toStringValue(_local4._arg2::cover_pid[0]);
                _local5.owner = _local4._arg2::owner;
                _local5.name = _local4._arg2::name;
                _local5.created = FacebookXMLParserUtils.toDate(_local4._arg2::created);
                _local5.modified = FacebookXMLParserUtils.toDate(_local4._arg2::modified);
                _local5.description = _local4._arg2::description;
                _local5.location = _local4._arg2::location;
                _local5.link = _local4._arg2::link;
                _local5.size = _local4._arg2::size;
                _local5.visible = _local4._arg2::visible;
                _local5.modified_major = FacebookXMLParserUtils.toDate(_local4._arg2::modified_major);
                _local5.edit_link = _local4._arg2::edit_link;
                _local5.type = _local4._arg2::type;
                _local3.addAlbum(_local5);
            };
            return (_local3);
        }
        public static function toNumber(_arg1:XML):Number{
            if (_arg1 == null){
                return (NaN);
            };
            return (Number(_arg1.toString()));
        }
        public static function toStringValue(_arg1:XML):String{
            if (_arg1 == null){
                return (null);
            };
            return (_arg1.toString());
        }
        public static function toDate(_arg1:String):Date{
            if (_arg1 == null){
                return (null);
            };
            var _local2:String = _arg1;
            while (_local2.length < 13) {
                _local2 = (_local2 + "0");
            };
            var _local3:Date = new Date(Number(_local2));
            return (_local3);
        }
        public static function xmlListToObjectArray(_arg1:XMLList):Array{
            var _local2:Array = [];
            if (_arg1 == null){
                return (_local2);
            };
            var _local3:uint = _arg1.length();
            var _local4:uint;
            while (_local4 < _local3) {
                _local2.push(xmlToObject(_arg1[_local4]));
                _local4++;
            };
            return (_local2);
        }
        public static function toUIDArray(_arg1:XML):Array{
            var _local2:Array = [];
            if (_arg1 == null){
                return (_local2);
            };
            var _local3:XMLList = _arg1.children();
            var _local4:uint = _local3.length();
            var _local5:uint;
            while (_local5 < _local4) {
                _local2.push(toNumber(_local3[_local5]));
                _local5++;
            };
            return (_local2);
        }
        public static function toBoolean(_arg1:XML):Boolean{
            if (_arg1 == null){
                return (false);
            };
            return ((_arg1.toString() == "1"));
        }
        public static function createLocation(_arg1:XML, _arg2:Namespace):FacebookLocation{
            var _local3:FacebookLocation = new FacebookLocation();
            if (_arg1 == null){
                return (_local3);
            };
            _local3.city = String(_arg1._arg2::city);
            _local3.state = String(_arg1._arg2::state);
            _local3.country = String(_arg1._arg2::country);
            _local3.zip = String(_arg1._arg2::zip);
            _local3.street = String(_arg1._arg2::street);
            return (_local3);
        }
        public static function xmlToObject(_arg1:XML):Object{
            var _local6:XML;
            var _local2:Object = {};
            var _local3:XMLList = _arg1.children();
            var _local4:uint = _local3.length();
            var _local5:uint;
            while (_local5 < _local4) {
                _local6 = _local3[_local5];
                _local2[_local6.localName()] = _local6.toString();
                _local5++;
            };
            return (_local2);
        }
        public static function xmlToUrlVariables(_arg1:XMLList):URLVariables{
            var _local3:XML;
            var _local2:URLVariables = new URLVariables();
            for each (_local3 in _arg1) {
                _local2[_local3.key.valueOf()] = _local3.value.valueOf();
            };
            return (_local2);
        }
        public static function nodeToObject(_arg1:XMLList):Object{
            var _local3:XML;
            var _local2:Object = {};
            for each (_local3 in _arg1) {
                _local2[_local3.key.valueOf()] = _local3.value.valueOf();
            };
            return (_local2);
        }
        public static function toArray(_arg1:XML):Array{
            if (_arg1 == null){
                return (null);
            };
            return (_arg1.toString().split(","));
        }

    }
}//package com.facebook.utils 
